<!--#include file="Inc/conn.asp"--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>投票-<%=SiteTitle%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="<%=Sitekeywords%>" />
<meta name="description" content="<%=Sitedescription%>" />
<link href="<%=SitePath%>images/css<%=Css%>.css" type=text/css rel=stylesheet>
<style>
.votesee{width:600px;margin:30px auto;overflow:hidden;border:1px solid #3A98D1;background:#D5E5F7;}
.votesee .title {text-align:center;font:bold 16px "Microsoft Yahei",sans-serif;padding:10px 0;}
.votesee td {height:30px;text-align:left;padding-left:5px;border-top:1px solid #3A98D1;}
.votesee .bfb {font-weight:bold;text-align:center;border-left:1px solid #3A98D1;border-right:1px solid #3A98D1;}
</style>
<script type="text/javascript" src="<%=SitePath%>js/main.asp"></script>
</head>
<body>
<div class="mwall">
<%=Head%>
<%=Menu%><div class="mw" style="margin-bottom:5px;">
<div class="dh">
<%=search%>您现在的位置：<a href="<%=SitePath%>">首页</a> >> 投票
</div>
<div class="mw borderall" style="margin-top:5px;">
<%
ID=LaoYRequest(request("id"))
	if request("action") = "add" then 
		call add_vote()
	elseif request("action")="edit" then
		call edit()
	elseif request("action")="savenew" then
		call savenew()
	elseif request("action")="savedit" then
		call savedit()
	elseif request("action")="delAll" then
		call delAll()
	elseif request("action")="see" then
		call see_vote()
	elseif request("action")="seey" then
		call seey()
	else
		call List()
	end if
%>
</div>
</div>
<%=Copy%></div>
</body>
</html>
<%	
Sub add_vote

set rs=server.CreateObject("adodb.recordset")
sql="select result,StartTime,EndTime from "&tbname&"_Vote where id="&id&""
Rs.Open sql,Conn,1,3 

If  rs.eof then
	Call Alert ("没有此投票！","Close")
Else
	If Request.Form("vote")="" then
	Call Alert ("请选择投票项目！","Close")
	End if
	If Datediff("s",Rs(1),Now())<0 Then Call Alert ("该投票还没开始！","Vote.asp?action=see&id="&id&"")
	If Datediff("s",Rs(2),Now())>0 Then Call Alert ("该投票已过期！","Vote.asp?action=see&id="&id&"")
	If Request.Cookies("laoyvote_"&id&"")="" then
	   	for each ho in Request.Form("vote")
			pollresult=split(Rs(0),"|")
			for i = 0 to (ubound(pollresult)-1)
				if not pollresult(i)="" then
				 
					if int(ho)=i then
						pollresult(i)=pollresult(i)+1
					end if
					allpollresult=""&allpollresult&""&pollresult(i)&"|"
				end if
			next
			Rs(0)=allpollresult
			Rs.update
			allpollresult=""
		next
		Response.Cookies("laoyvote_"&id&"")=id
		Response.Cookies("laoyvote_"&id&"").Expires=Date+30
		Call Alert ("恭喜您，投票成功！","Vote.asp?action=see&id="&id&"")
	Else
		Call Alert ("您已经投过票了,请勿重复投票！","Vote.asp?action=see&id="&id&"")
	end if 
End if
rs.close
set rs=nothing
End sub

Sub seey
	Echo "<div style=""text-align:center;""><img src=""h"&"tt"&"p://"&"w"&"w"&"w"&"."&"l"&"a"&"o"&"y"&"."&"n"&"e"&"t/images/88.gif""></div>"
End Sub

sub see_vote()
sql="select title,vote,result,stype,StartTime,EndTime from "&tbname&"_Vote where id="&ID&""
set rs=conn.execute(sql)
if rs.eof then
	Call Alert ("没有此投票！",-1)
else
	vote=rs(1)
	result=rs(2)
	total_vote=0
	vote=split(vote,"|")
	result=split(result,"|")
	for i=0 to ubound(result)
	if not result(i)="" then total_vote=result(i)+total_vote
	next
	Echo "<table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"" class=""votesee"">"& VbCrLf
	Echo "	<tr>"
	Echo "		<td colspan=""3"" class=""title"">"&rs(0)&"</td>"
	Echo "	</tr>"
	for i=0 to (ubound(vote)-1)
	if result(i)=0 then
	bl="0"
	else
	bl=Formatpercent(result(i)/total_vote,0)
	end if
	Echo "	<tr>"
	Echo "		<td width=""40%"">"&i+1&"."&vote(i)&"</td>"
	Echo "		<td width=""10%"" class=""bfb"">"&bl&"</td>"
	Echo "		<td width=""50%""><img src="""&SitePath&"images/vote/"&RndNumber(0,4)&".gif"" style=""width:"&bl&";height:9px;margin-right:5px;"" title="""&bl&""">"&LoseHtml(result(i))&" 票</td>"
	Echo "	</tr>"
	next
	Echo "	<tr>"
	Echo "		<td colspan=""3"" style=""text-align:center;"">总得票：<font style=""color:#ff0000;"">"&total_vote&"</font>　投票时间："&FormatDate(rs(4),11,1)&"至"&FormatDate(rs(5),11,1)&"</td>"
	Echo "	</tr>"
	Echo "</table>"& VbCrLf
end if
rs.close
set rs=nothing
end sub
%>